﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UI;

public class CCGSelectRewardItem : MonoBehaviour
{
    public CommonIcon icon;
    public UILabel nameLabel;
    public GameObject selectTip;

    bool isSelect = false;
    ProtoBuf.Message.BaseResource baseResource;

    UIEventListener.VoidDelegate onClick;
    public void Init(ProtoBuf.Message.BaseResource res, bool selected, UIEventListener.VoidDelegate onClick)
    {
        baseResource = res;
        icon.SetData(res.id, false, res.num);
        nameLabel.text = TableTextBlo.GetText(CommonMethod.GetObjectNameTextId(res.id));
        isSelect = selected;
        selectTip.SetActive(isSelect);
        this.onClick = onClick;
    }

    public string GetCurItemId()
    {
        return baseResource.id;
    }

    void OnClick()
    {
        if (onClick != null)
        {
            onClick(gameObject);
        }

    }


    public void Select()
    {
        isSelect = true;
        selectTip.SetActive(isSelect);
    }

    public void UnSelect()
    {
        isSelect = false;
        selectTip.SetActive(isSelect);
    }

}